package com.example.ruihuada.ui.HomeModule.frament

import android.os.Bundle
import com.example.ruihuada.R
import com.example.ruihuada.base.BaseFragment
import com.example.ruihuada.base.FragmentPagerItem
import com.example.ruihuada.base.FragmentPagerItemAdapter
import com.example.ruihuada.base.FragmentPagerItems
import com.example.util.onPageSelected
import kotlinx.android.synthetic.main.fragment_social_circle.*


/**
 *
 * ul 圈子
 */
class SocialCircleFragment : BaseFragment() {
    val titles = arrayOf("最新", "热榜", "关注", "圈子", "达人视频")
    lateinit var pageAdapter: FragmentPagerItemAdapter

    override fun getLayoutId(): Int = R.layout.fragment_social_circle

    override fun initView() {
        val pages = FragmentPagerItems(mContext)
        for (x in titles.indices) {
            pages.add(
                FragmentPagerItem.of(
                    titles[x],
                    HotFragment::class.java,
                    Bundle().apply {
                        putInt("type", x)
                    })
            )
        }
        pageAdapter = FragmentPagerItemAdapter(fragmentManager, pages)
        viewPager.adapter = pageAdapter
        smartTabLayout.setViewPager(viewPager)

        smartTabLayout.setOnTabClickListener {
            setBoldForTab(it)
        }
        viewPager.onPageSelected { setBoldForTab(it) }
        setBoldForTab(0)


    }

    private fun setBoldForTab(position: Int) {
        for (x in 0 until 6) {
//            smartTabLayout.getTabAt(x)
//                .findViewById<TextView>(R.id.custom_text)?.paint?.isFakeBoldText = x == position
        }
    }


}